<template>
    <section class="mainSection roleManagementSection">
        <common-toolbar text="角色管理"></common-toolbar>
        <div class="">
            <div class="left">
                <div class="top bluetopLine relative">
                    <div class="bdbottomD4D8DA topTitleView">
                        <i class="blueBlock"></i>
                        <span class="littleTop">角色管理</span>
                        <p class="fontClass fr">
                           <!-- <i class="treeAddIcon" @click.stop="AddRole()"></i>
                            <i class="treeEditIcon" @click="ChangeTreeName()"></i>
                            <i class="treeDelIcon" @click="DeleteTree()"></i>-->
                            <i class="fa fa-plus-square" @click="AddRole()"></i>
                            <i class="fa fa-eyedropper" @click="ChangeTreeName()"></i>
                            <i class="fa fa-times-rectangle" @click="DeleteTree()"></i>
                        </p>
                    </div>
                </div>
                <div class="bottom bgcWight pd5">
                    <!-- {{roleData}} -->
                    <!-- <common-vxeTable
                        :tableData="roleData"
                        :tableHeight="bodyHeight"
                        :columns="columns"
                        :autoResize ="true"
                        :loading="listLoading"
                        @cellClick="cellClick"
                        class="w100"
                    >
                    </common-vxeTable> -->
                    <el-table @cell-click="cellClick" :height="bodyHeight" :data="roleData" style="width: 100%" class="indexTable containTable" :row-class-name="tableRowClassName">
                        <el-table-column prop="roleName" label="角色名称" show-overflow-tooltip="true">
                            
                            <template slot-scope="scope">
                                {{scope.row.headquartersName}} <span v-if="scope.row.roleName!=null&&scope.row.headquartersName!=null">-</span> {{scope.row.roleName}} 
                            </template>
                        </el-table-column>
                        <el-table-column prop="type" label="角色类型">
                            <!-- <template slot-scope="scope">
                                <span v-if="0 == scope.row.roleType">三员角色</span>
                                <span v-if="1 == scope.row.roleType">系统角色</span>
                                <span v-if="2 == scope.row.roleType">全宗角色</span>
                            </template> -->
                        </el-table-column>
                    </el-table>
                </div>
            </div>
            <div class="right" style="border:0px;">
                <div class="top bluetopLine relative">
                   <!-- <div class="bdbottomD4D8DA topTitleView">
                        <i class="blueBlock"></i>
                        <span class="littleTop">权限菜单配置</span>
                    </div>-->
                    <el-radio-group v-model="tabPosition" style="margin-bottom: 30px;" @change="radioChange" >
                        <el-radio-button label="function">菜单权限配置</el-radio-button>
                        <el-radio-button label="data">数据权限配置</el-radio-button>
                    </el-radio-group>
                </div>
                <div class="div1"  :style="contentStyle" v-show="tabPosition=='function'">
                    <common-tree2 :data="pageData"
                                  nodeKey="functionCode"
                                 ref="commonTree"
                                 :defaultProps="{
                                        children: 'children',
                                        label: 'name'
                                    }"
                                  :checkStrictly="checkStrictly"
                                  :showCheckbox="true"
                                  :expandAll="true"
                                  @check-change="checkboxChanged1"
                                  :checkedKeys="checkedKeys"
                                 :expandOnClickNode="false">
                    </common-tree2>
                </div>
                <div class="div1"  :style="contentStyle" v-show="tabPosition=='data'">
                    <common-tree2 :data="cinemaList"
                                  nodeKey="cinemaCode"
                                  ref="commonTree1"
                                  :defaultProps="{
                                        children: 'children',
                                        label: 'cinemaNameCn'
                                    }"
                                  :checkStrictly="checkStrictly1"
                                  :showCheckbox="true"
                                  :expandAll="true"
                                  @check-change="checkboxChanged"
                                  :checkedKeys="checkedKeys1"
                                  :expandOnClickNode="false">
                    </common-tree2>
                </div>
                <div class="rbottom">
                    <common-button text="确定" @click="applySubmit('ruleForm')"></common-button>
                </div>
            </div>
            <div class="clear"></div>
        </div>
        <el-dialog class="myDialog" title="新增角色" :visible.sync="fileVisible" :close-on-click-modal="true">
            <div class="scrollCon formDiv">
                <div class="tableCon">
                    <el-form :model="fileForm" label-width="100px" :rules="fileFormRules" ref="fileForm" class="showErrorFormView">
                        <el-form-item :show-message="false" label="角色名称：" class="basicItem" ref="roleName" prop="roleName">
                            <el-tooltip style="width: 20%;padding: 9px 0;" class="item" effect="dark" :content="headquartersName" placement="top-start">
                            <el-button readonly  style="white-space: nowrap;text-overflow: ellipsis;overflow: hidden;">{{headquartersName}}</el-button>
                            </el-tooltip>
                            <!-- <common-input class="checkName percentName" placeholder="最多输入50个字符" maxlength="50" v-model.trim="fileForm.roleName" type="text"></common-input> -->
                            <common-input placeholder="最多输入50个字符"
                                    type="text"
                                    :clearable="true"
                                    size="small"
                                    :maxlength="50"
                                    v-model.trim="fileForm.roleName"  style="width:70%"
                            ></common-input>
                        </el-form-item>
                        <el-form-item :show-message="false" label="角色类型：" class="basicItem" ref="roleName" prop="roleType">
                            <el-select v-model="fileForm.roleType" placeholder="请选择角色类型">
                                <el-option
                                v-for="item in roleTypeOptions"
                                :key="item.value"
                                :label="item.label"
                                :value="item.value">
                                </el-option>
                            </el-select>
                            <!-- <common-select
                                placeholder="请选择角色类型"
                                :data="roleTypeOptions"
                                v-model="fileForm.roleType"
                                class="w100"
                            ></common-select> -->
                        </el-form-item>
                        <!-- <el-form-item :show-message="false" label="查看范围：" class="basicItem" ref="roleName" prop="viewRange">
                            <common-select
                                placeholder="请选择查看范围"
                                :data="viewRangeOptions"
                                v-model="fileForm.viewRange"
                                class="w100"
                            ></common-select>
                        </el-form-item> -->
                        <el-form-item :show-message="false" label="备注：" class="basicItem" style="margin-top:15px;">
                            <common-input placeholder="请输入备注"
                                    type="textarea"
                                    :clearable="true"
                                    v-model.trim="fileForm.description"
                            ></common-input>
                            <!-- <el-input class="checkName percentName" type="textarea" v-model="fileForm.description"></el-input> -->
                        </el-form-item>
                    </el-form>
                </div>
            </div>
            <div slot="footer" class="dialog-footer diaFoot">
                <common-button text="确定" @click="submitForm('fileForm')"></common-button>
            </div>
        </el-dialog>
        <el-dialog class="myDialog" title="编辑角色" :visible.sync="fileVisible1" :close-on-click-modal="true">
            <div class="scrollCon formDiv">
                <div class="tableCon">
                    <el-form :model="fileForm1" label-width="100px" :rules="fileFormRules1" ref="fileForm1" class="showErrorFormView">
                        <el-form-item :show-message="false" label="角色名称：" class="basicItem" ref="roleName" prop="roleName">
                            <el-tooltip style="width: 20%;padding: 9px 0;" class="item" effect="dark" :content="fileForm1.headquartersName" placement="top-start">
                            <el-button readonly style="white-space: nowrap;text-overflow: ellipsis;overflow: hidden;">{{fileForm1.headquartersName}}</el-button>
                            </el-tooltip>
                            <!-- <el-input style="width: 20%;" readonly v-model.trim="fileForm1.headquartersName">{{fileForm1.headquartersName}}</el-input> -->
                            <common-input placeholder="最多输入50个字符"
                                    type="text"
                                    :clearable="true"
                                    size="small"
                                    :maxlength="50"
                                    v-model.trim="fileForm1.roleName" style="width:70%"
                            ></common-input>
                        </el-form-item>
                         <el-form-item :show-message="false" label="角色类型：" class="basicItem" ref="roleName"  prop="roleType">
                           <el-select v-model="fileForm1.roleType" placeholder="请选择角色类型">
                                <el-option
                                v-for="item in roleTypeOptions"
                                :key="item.value"
                                :label="item.label"
                                :value="item.value">
                                </el-option>
                            </el-select>
                            <!-- <common-select
                                placeholder="请选择角色类型"
                                :data="roleTypeOptions"
                                :disabled="fileForm1.type==0"
                                v-model="fileForm1.roleType"
                            ></common-select> -->
                        </el-form-item>
                        <!-- <el-form-item :show-message="false" label="查看范围：" class="basicItem" ref="roleName">
                            <common-select
                                placeholder="请选择查看范围"
                                :data="viewRangeOptions"
                                :disabled="fileForm1.type==0"
                                v-model="fileForm1.viewRange"
                            ></common-select>
                        </el-form-item> -->
                        <el-form-item :show-message="false" label="备注：" class="basicItem" style="margin-top:8px;">
                            <common-input placeholder="请输入备注"
                                    type="textarea"
                                    :clearable="true"
                                    v-model.trim="fileForm1.description"
                            ></common-input>
                        </el-form-item>
                    </el-form>
                </div>
            </div>
            <div slot="footer" class="dialog-footer diaFoot">
                <el-button type="primary" class="defaultBtn" @click="submitForm1('fileForm1')">保存</el-button>
            </div>
        </el-dialog>
    </section>
</template>

<script lang="ts">
    import Vue from 'vue';
    import Component from 'vue-class-component';
    import Service from './roleManagement.service';
    @Component
    export default class approleManagement extends Vue{
        fileVisible:boolean;
        fileVisible1:boolean;
        bodyHeight: number;
        roleData: any = [];
        listLoading:boolean = false;
        pageData: any = [];
        activeNames: any = [];
        viewRangeOptions:any = [];
        roleTypeOptions:any = [];
        formInline = {};
        contentStyle = {
            "height":document.documentElement.clientHeight - 220 + "px",
            "overflow-y":'auto'
        };
        detailDiv:any = [];
        b: any = [];
        columns = [
        {
          title: "角色名称",
          field: "roleName",
        },
        {
          title: "角色类型",
          field: "type",
        },
      ];
        functionColumns = [
            {
                label: "功能",
                prop: "name",
                align:"left",
                treeNode:true,
            },
        ]
        roleId:number;
        fileForm = {};
        fileFormRules = {};
        fileForm1 = {};
        fileFormRules1 = {};
        obj = {};
        ziDian = [];
        selectedCheckboxChanged=[];
        RoleCategoryList = [];
        height:number

        chooseList = [];

        checkboxConfig={
            checkRowKeys: []
        };

        checkedKeys = [];
        checkedKeys1=[];

        selected = [];

        checkStrictly = true;
        checkStrictly1 = true;

        tabPosition = 'function';
        headquartersName='';
        cinemaList = [];

        constructor(){
            super();
            this.height = document.documentElement.clientHeight
            this.bodyHeight = document.documentElement.clientHeight - 190;
            this.fileVisible = false;
            this.fileVisible1 = false;
            this.roleData = [];
            this.formInline = {
                functionCode:'',
                type:[],
            };
            this.roleId = 0;
            this.fileForm = {
                roleName:'',
                description:'',
                roleType:'',
                viewRange:'',
                headquartersName:''
            };
            this.fileFormRules = {
                roleName:[
                    { required: true, message: '请填写角色名称', trigger: 'blur' }
                ],
                roleType:[
                    { required: true, message: '请选择角色类型', trigger: 'change' }
                ],
                viewRange:[
                    { required: true, message: '请选择查看范围', trigger: 'change' }
                ]
            };
            this.fileForm1 = {
                roleName:'',
                description:'',
                roleType:'',
                viewRange:'',
                fileForm1:''
            };
            this.fileFormRules1 = {
                roleName:[
                    { required: true, message: '请填写', trigger: 'blur' }
                ],
                roleType:[
                    { required: true, message: '请选择角色类型', trigger: 'change' }
                ],
                viewRange:[
                    { required: true, message: '请选择查看范围', trigger: 'change' }
                ]
            };
            this.obj = {};
            this.ziDian = [];
        }

        //新增角色
        AddRole(){
            this.fileForm.roleName = '';
            this.fileForm.description = '';
            let userInfoForm = JSON.parse(window.sessionStorage.getItem('userInfoForm'));
            //console.log(userInfoForm)
            this.headquartersName = userInfoForm.headquartersName;
            this.fileVisible = true;
        }
        //编辑角色
        ChangeTreeName(){
            if(Object.keys(this.obj).length == 0){
                this['$message']({
                    message: '请选择角色！',
                    type: 'warning'
                });
                return;
            }else if(this.obj.roleType == 0 || this.obj.roleType == 2){
                this['$message']({
                    message: '该角色不可编辑！',
                    type: 'warning'
                });
                return;
            }
            //console.log(this.obj)
            this.fileForm1.roleName = this.obj.roleName;
            this.fileForm1.description = this.obj.description;
            this.fileForm1.roleType = this.obj.category;
            this.fileForm1.type = this.obj.type;
            this.fileForm1.viewRange = this.obj.scope;
            this.fileForm1.roleType = this.obj.type;
            this.fileForm1.headquartersName = this.obj.headquartersName;
            this.fileVisible1 = true;
        }
        //删除角色
        DeleteTree(){
            if(Object.keys(this.obj).length == 0){
                this['$message']({
                    message: '请选择角色！',
                    type: 'warning'
                });
                return;
            }else if(this.obj.roleType == 0 || this.obj.roleType == 2){
                 this['$message']({
                     message: '该角色不可删除！',
                     type: 'warning'
                 });
                 return;
            }
            this['$confirm']('确定要删除吗?','删除角色', {
                iconClass:'askInformation',
                confirmButtonText: '确定',
                cancelButtonText: '取消',
            }).then(() => {
                Service.del({id:this.obj.id}).then((res) =>{
                    if(res.data.succeeded){
                        this['$message']({
                            message: '删除成功！',
                            type: 'success'
                        });
                        this.getFiles();
                    }else{
                        this['$message']({
                            message: res.data.errorMessage,
                            type: 'error'
                        });
                    }
                });
            }).catch(() => {
                this['$message']({
                    type: 'info',
                    message: '已取消删除'
                });
            });
        }
        radioChange(val) {
            //console.log(val)
            if(this.roleId!=undefined) {
                this.getPower(this.roleId)
            }
        }
        //获取权限
        getPower(row){
            const me = this;
            
            if(this.tabPosition == 'data' ){
                me.checkStrictly1 = true;
                let userInfoForm = JSON.parse(window.sessionStorage.getItem('userInfoForm'));
                if(userInfoForm.userName == 'admin') {
                     let params = {
                        pageNum: 0,
                        pageSize: 0,
                        cinemaName: null,
                        cinemaCode: null,
                        headquartersCode:row.headquartersCode
                    }
                    Service.bindCinemaList(params).then((res) =>{
                        //console.log(res)
                        this.cinemaList= res.data.data
                    });
                }
                Service.finAll({roleId:row.id}).then((res) =>{
                    this.formInline.type = [];
                    let attr = res.data.data;
                    me.checkedKeys1 = [];
                    this.$refs.commonTree1.setCheckedKeys([])
                    for(let item of attr){
                        this.formInline.type.push(item.cinemaCode);
                        this.checkedKeys1.push(item.cinemaCode)
                    }

                    setTimeout(function(){
                        me.$refs.commonTree.setCheckedKeys(me.checkedKeys1)
                        me.checkStrictly1 = false;

                    },100)
                });
            }
            else {
                // //console.log(id,'++++++++++++++++++++++')
                me.checkStrictly = true;
                Service.getRoleFunction({roleId:row.id}).then((res) =>{
                    this.formInline.type = [];
                    this.checkedKeys=[]
                    let attr = res.data.data;
                    me.checkedKeys = [];
                    this.$refs.commonTree.setCheckedKeys([])
                    for(let item of attr){
                        this.formInline.type.push(item.functionCode);
                        this.checkedKeys.push(item.functionCode)
                    }
    
                    setTimeout(function(){
                        me.$refs.commonTree.setCheckedKeys(me.checkedKeys)
                        me.checkStrictly = false;
    
                    },100)
                });
            }
            
        }
        // 获取页面查看范围
        roleScopeCandidates() {
            Service.roleScopeCandidates({}).then((res) =>{
                if(res.data.succeeded) {
                    this.viewRangeOptions = [];
                    for(let item of res.data.data){
                        this.viewRangeOptions.push({value:parseInt(item.code),label:item.displayText});
                    }
                }
            });
        }
        //确定
        submitForm(form){
            this['$refs'][form]['validate']((valid)=>{
                if (valid) {
                    // let parames = {
                    //     roleName:this.fileForm.roleName,
                    //     description:this.fileForm.description,
                    //     roleCode:null,
                    //     scope:parseInt(this.fileForm.viewRange),
                    //     category:this.fileForm.roleType,
                    // };
                    //console.log(this.fileForm,this.obj)
                    let parames = {
                        roleName:this.fileForm.roleName,
                        description:this.fileForm.description,
                        // id:this.obj.id,
                        type:this.fileForm.roleType,
                        headquartersName:this.headquartersName
                    };
                    Service.saveOrUpdateRole(parames).then((res) =>{
                        if(res.data.succeeded){
                            this['$message']({
                                message: '新增成功！',
                                type: 'success'
                            });
                            this.fileVisible = false;
                            this.obj = {};
                            this.checkedKeys = [];
                            this.getFiles();
                        }else{
                            this['$message']({
                                message: res.data.errorMessage,
                                type: 'error'
                            });
                        }
                    });
                }
            });
        }

        submitForm1(form){
            this['$refs'][form]['validate']((valid)=>{
                if (valid) {
                    let type =''
                    //console.log(typeof(this.fileForm1.roleType))
                    if(typeof(this.fileForm1.roleType)=='string') {
                        for(let item of this.roleTypeOptions) {
                            if(this.fileForm1.roleType==item.label) {
                                type =item.value
                            }
                        }
                        
                    }
                    let parames = {
                        roleName:this.fileForm1.roleName,
                        description:this.fileForm1.description,
                        headquartersName:this.fileForm1.headquartersName,
                        id:this.obj.id,
                        type:typeof(this.fileForm1.roleType)=='string'?type:this.fileForm1.roleType,
                    };
                    if(this.obj.type ==1){
                        parames['scope'] = parseInt(this.fileForm1.viewRange);
                        parames['category'] = this.fileForm1.roleType;
                    }
                   Service.saveOrUpdateRole(parames).then((res) =>{
                        if(res.data.succeeded){
                            this['$message']({
                                message: '修改成功！',
                                type: 'success'
                            });
                            this.fileVisible1 = false;
                            this.obj = {};
                            this.checkedKeys = [];
                            this.getFiles();
                        }else{
                            this['$message']({
                                message: res.data.errorMessage,
                                type: 'error'
                            });
                        }
                    });
                }
            });
        }

        getPageData() {
            Service.getPageList({}).then((res) => {//获取菜单页面权限
                this.pageData = res.data.data;
                for (let child of this.pageData) {
                    this.detailDiv.push("detail" + child.id);
                }
            });
            let me = this
             let userInfoForm = JSON.parse(window.sessionStorage.getItem('userInfoForm'));
                if(userInfoForm.userName == 'admin') {
                     let params = {
                        pageNum: 0,
                        pageSize: 0,
                        cinemaName: null,
                        cinemaCode: null,
                    }
                    Service.bindCinemaList(params).then((res) =>{
                        this.cinemaList= res.data.data
                    });
                }else{
                    Service.byHeadquartersCode(false).then((res) =>{
                        //console.log(res,'111111111111111')
                        if(res.succeeded){
                            //console.log(res.data)
                            this.cinemaList= res.data
                            // this['$message']({
                            //     message: '修改成功！',
                            //     type: 'success'
                            // });
                            // this.fileVisible1 = false;
                            // this.obj = {};
                            // this.checkedKeys = [];
                            // this.getFiles();
                        }else{
                            this['$message']({
                                message: res.data.errorMessage,
                                type: 'error'
                            });
                        }
                    });
                }
            
            // this.cinemaList = [];
            
            // for (let i = 0; i < 50; i++) {
            //     this.cinemaList.push({
            //         name: '影院名称' + i;
            //      });
            // }
        }

        detailDiv1(obj){
            return "detail"+obj;
        }

        checkMethod(){

        }

        getFiles():void {
            const me = this;
            me.listLoading = true;
            setTimeout(function () {
                Service.getRoleList({}).then((res) => {//角色列表
                    for(let item of res.data.data) {
                        for(let items of me.roleTypeOptions) {
                            if(item.type == items.value) {
                                item.type = items.label
                            }
                        }
                        // if(item.type == 1) {
                        //     item.type ='系统内置角色'
                        // } else if(item.type == 0) {
                        //     item.type ='男'
                        // }
                    }
                     me.roleData = res.data.data;
                });
                me.listLoading = false;
                me.getPageData();
            }, 100);
        }
        // 获取角色类型
        getRoleCategoryList() {
            // let parames={codeType:'sex'}
            Service.byType().then((res) =>{//角色列表
            //console.log(res.data,res)
                if(res.succeeded) {
                    // this.roleTypeOptions = res.data.data;
                    for(let item of res.data) {
                        //console.log(item)
                        this.roleTypeOptions.push({value:item.codeId,label:item.codeValue});
                    }
                    //console.log(this.roleTypeOptions)
                } else {
                    this['$backErrorInformation'](res.data.errorMessage);
                }
            });
        }
        detail(obj,item){
            let flag = false;
            for(let child of item.children){
                if(child.children.length != 0){
                    flag = true;
                }
            }
            if(!flag){
                this['$message']({
                    message: '该列没有按钮权限！',
                    type: 'warning'
                });
                return;
            }
            let v = document.getElementById(this.detailDiv[obj]);
            if(this.detailDiv[obj] == v.id){
                if(v.style.display == 'none'){
                    v.style.display="";
                }else{
                    v.style.display="none";
                }
            }


        }
        handleChange(){
            this.activeNames = [];
        }

        cellClick(row, column, cell, event){
            //if(column.property == 'roleName'){
                //console.log(row, column, cell, event)
                this.getPower(row);
                this.roleId = row;
                this.obj = row;
                 return 'success-row';
            //}
        }
        tableRowClassName({row, rowIndex}) {
            //console.log(row)
            if(this.roleId.id==row.id) {
                return 'success-row';
            }
            return ''
        }
        cellStyle({row, column, rowIndex, columnIndex}){
            if(columnIndex === 0){//指定列号
                return 'background:#ebeef5'
            }else{
                return ''
            }
        }

        applySubmit(form){
//            let ids = this.formInline.type;
//console.log(this.tabPosition + '------------------------------------------')
            let selected = this.$refs.commonTree.getCheckedNodes().concat(this.$refs.commonTree.getHalfCheckedNodes());
            //console.log(selected)
            //console.log('----------------------------')
            let ids = [],id=[];
            for(let node of selected){
                ids.push(node.functionCode);
            }
            if(this.roleId == 0){
                this['$message']({
                    message: '请选择角色！',
                    type: 'warning'
                });
                return;
            }else if(ids == []){
                this['$message']({
                    message: '请选择权限！',
                    type: 'warning'
                });
                return;
            }else if(this.obj.roleType == 0 || this.obj.roleType == 2){
                 this['$message']({
                     message: '该角色不可分配菜单权限！',
                     type: 'warning'
                 });
                 return;
            }
            let parames = {
               
            };
            if(this.tabPosition == 'data' ){
                id=[];
                let selected = this.$refs.commonTree1.getCheckedNodes().concat(this.$refs.commonTree1.getHalfCheckedNodes());
               //console.log(selected)
               for(let item of selected) {
                    //console.log(item,'+++++++++++++')
                    id.push(item.cinemaCode)
                }
                parames = {
                     roleId:this.roleId.id,
                cinemaCodes:id,
                }
                Service.cinemaUpdate(parames).then(res=>{
                    //console.log(res)
                    if(res.succeeded){
//                    this.getFiles();
                        this['$message']({
                            message: '修改成功！',
                            type: 'success'
                        });
                    }else{
                        this['$message']({
                            message: res.data.errorMessage,
                            type: 'error'
                        });
                    }
                })
            } else {
                 parames = {
                     roleId:this.roleId.id,
                functionCodes:ids,
                }
                Service.updateRoleFunction(parames).then((res) =>{//角色列表
                    if(res.data.succeeded){
    //                    this.getFiles();
                        this['$message']({
                            message: '修改成功！',
                            type: 'success'
                        });
                    }else{
                        this['$message']({
                            message: res.data.errorMessage,
                            type: 'error'
                        });
                    }
                });
            }
            
        }

        checkChild(val,obj){
            if(val){
                for(let child of obj.children){
                    if(this.formInline.type.indexOf(child.functionCode) < 0){
                        this.formInline.type.push(child.functionCode);
                    }
                }
            }else{
                for(let i = 0;i <  this.formInline.type.length;i++){
                    for(let child1 of obj.children){
                        if(this.formInline.type[i] == child1.functionCode){
                            let index = this.formInline.type.indexOf(this.formInline.type[i]);
                            this.formInline.type.splice(index,1);
                            i--;
                        }
                    }
                }
            }
        }

        checkParent(val,obj){
            if(val){
                for(let child of this.pageData){
                    for(let child1 of child.children){
                        if(child1.functionCode == obj.functionCode && this.formInline.type.indexOf(child.functionCode) < 0){
                            this.formInline.type.push(child.functionCode);
                        }
                    }
                }
            }
        }
        // 单选父组件返回数据
        selectChangeEvent(checked, records) {
            this.chooseList = records;
        };
        getRowKeys(){
            return 'functionCode'
        }
        checkboxChanged1(row) {
            this.selected = row;
            
            // let parames = {
            //     roleId:row.id
            // }
            // Service.byHeadquartersCode({}).then((res) =>{
            //     if(res.data.succeeded){
            //         //console.log(res.data)
            //         this.cinemaList= res.data.data
            //         // this['$message']({
            //         //     message: '修改成功！',
            //         //     type: 'success'
            //         // });
            //         // this.fileVisible1 = false;
            //         // this.obj = {};
            //         // this.checkedKeys = [];
            //         // this.getFiles();
            //     }else{
            //         this['$message']({
            //             message: res.data.errorMessage,
            //             type: 'error'
            //         });
            //     }
            // });
        }
        checkboxChanged(row) {
            //console.log(row)
           this.selected = row;
        //    this.selectedCheckboxChanged.push(row)
           this.selectedCheckboxChanged = row

//            let selected = this.$refs.commonTree.getCheckedNodes()
//            //console.log(selected);
        }

        created() {
            this.getRoleCategoryList();
            this.roleScopeCandidates();
            
        };
        mounted() {
            this.getFiles();
            window.onresize = () => {
                return (() => {
                    this.bodyHeight = document.documentElement.clientHeight - 190;
                    this.contentStyle = {
                        "height": document.documentElement.clientHeight - 120 + "px",
                        "overflow-y": 'auto'
                    };
                })()
            };
        };
    };
</script>

<style lang="scss" scoped>
    @import '../../../styles/system/roleManagement/roleManagement.scss';
    /deep/ .el-table .success-row {
        background: #d4e6ff;
    }
</style>